<?php if (count($currencies) > 1) { ?>
    <div style="display: inline-block">
        <a id="open_currencies" data-role="button"><?php echo $text_currency; ?></a>
        <?php
        $curr_html = '';
        foreach ($currencies as $currency) {
            $curr_html .= '<form action=\'' . $action . '\' method=\'post\' enctype=\'multipart/form-data\'>';
            if ($currency['symbol_left']) {
                $curr_html .= '<input type=\'submit\' alt=\'' . $currency['title'] . '\' value=\'' . $currency['symbol_left'] . '\'' . ($currency['code'] == $currency_code ? ' disabled=\'disabled\'' : '') . ' />';
            } else {
                $curr_html .= '<input type=\'submit\' alt=\'' . $currency['title'] . '\' value=\'' . $currency['symbol_right'] . '\'' . ($currency['code'] == $currency_code ? ' disabled=\'disabled\'' : '') . ' />';
            }
            $curr_html .= '<input type=\'hidden\' name=\'currency_code\' value=\'' . $currency['code'] . '\' /><input type=\'hidden\' name=\'redirect\' value=\'' . $redirect . '\' />';
            $curr_html .= '</form>';
        }
        ?>
        <script type="text/javascript">
            $(document).delegate('#open_currencies', 'click', function() {
                $(this).simpledialog({
                    'mode': 'blank',
                    'prompt': false,
                    'forceInput': false,
                    'useModal':true,
                    'fullHTML':
                        "<?php echo $curr_html ?><a rel='close' data-role='button' href='#' id='simpleclose'>Close</a>"
                })
            });
        </script>
    </div>
<?php } ?>